<?php

class Form_Room extends Zend_Form
{
    const  ZONE_MAX    = 3;
    const  ZONE_FACTOR = 16;
    
    
    public function init()
    {
    }
    
    protected function addCommon($scale)
    {
      $this->addAttribs(array(
        'class'=>'room-form',
      ));

    
      $this->setMethod('post');

      $this->addElement('text', 'name', array(
        'label'      => 'Name:',
        'required'   => true 
      ));

      $this->addElement('text', 'setpoint', array(
        'label'      => 'Setpoint (' . $scale . '):',
        'class'      => 'setpt',
        'required'   => true
      ));
    
      // zones 
      $zone = new Zend_Form_Element_Select('zone_id');
      $zone->setLabel('Zone:');
      $zone->setRequired(true);
      $zone->addMultiOption("null", "-- Select --");
      for ($i=1; $i < Form_Room::ZONE_MAX+1; $i++) {
        $zone->addMultiOption(($i * Form_Room::ZONE_FACTOR), $i);
      }
      $this->addElement($zone);
    }
    
    public function getAddForm($scale) {
      $this->addCommon($scale);      

      // add the submit button
      $this->addElement('submit', 'submit',  array(
                        'label'    => 'Add',
                        ));
    
    }
    
    
    
    public function getEditForm($scale) {
      $this->addCommon($scale);
      $this->addElement('hidden', 'room_id'); 
      // add the submit button
      $this->addElement('submit', 'submit',  array(
                        'label'    => 'Edit',
                        ));
    
    }
    
}